//
//  MockNetworkClient.swift
//  PorscheRegistration
//
//  Created by Jinzhu Liu on 2023/11/28.
//

import Foundation
import Combine

enum MockNetworkClientError: Error {
    case NetworkError
}


class MockNetworkClient {
    
    private static let queue = DispatchQueue(label: "Network")
    
    public static func uploadRegistData(_ data: Data) -> AnyPublisher<Bool, Error> {
        let source = PassthroughSubject<Bool, Error>()
        
        self.queue.asyncAfter(deadline: DispatchTime.now() + .seconds(3)) {
            source.send(true)
        }
        
        return source.eraseToAnyPublisher()
    }
    
    public static func uploadImageData(_ data: Data) -> AnyPublisher<String, Error> {
        let source = PassthroughSubject<String, Error>()
        
        self.queue.asyncAfter(deadline: DispatchTime.now() + .seconds(3)) {
            let imageId = UUID().uuidString
            source.send(imageId)
        }
        
        return source.eraseToAnyPublisher()
    }
}
